//this module defines functions to access and modify PCBs

#include "pcb.h"

/* setters */

void pcb_set_priority(PCB* target, int32_t priority) {
  target->priority = priority;
}

void pcb_set_pid(PCB* target, int32_t pid) {
  target->pid = pid;
}

void pcb_set_in_use(PCB* target, uint8_t in_use) {
  target->in_use = in_use;
}

void pcb_set_epc(PCB* target, uint32_t pc){
  target->registers.epc_reg = pc;
}

void pcb_set_state(PCB* target, uint32_t state){
  target->state = state;
}

void pcb_set_sp(PCB* target, uint32_t address){
  target->registers.sp_reg = address;
}

void pcb_set_delay(PCB* target, uint32_t delay){
  target->delay = delay;
}

void pcb_set_program_id(PCB* target, int32_t program_id){
  target->program_id = program_id;
}

void pcb_set_parent(PCB* target, int32_t parent){
  target->parent = parent;
}

void pcb_set_waiting_for(PCB* target, int32_t pid){
  target->waiting_for = pid;
}

void pcb_set_status(PCB* target, int32_t status){
  target->status = status;
}

/* getters */

int32_t pcb_get_priority(PCB* target){
  return target->priority;
}

int32_t pcb_get_pid(PCB* target){
  return target->pid;
}

uint32_t pcb_get_state(PCB* target){
  return target->state;
}

uint8_t pcb_get_in_use(PCB* target){
  return target->in_use;
}

uint32_t pcb_get_delay(PCB* target){
  return target->delay;
}

uint32_t pcb_get_epc(PCB* target){
  return target->registers.epc_reg;
}

/* returns a pointer to the registers field of a PCB */
registers_t* pcb_get_registers(PCB* target){
  return &(target->registers);
}

int32_t pcb_get_program_id(PCB* target){
  return target->program_id;
}

/* returns a pointer to the message queue of the PCB */
message_queue* pcb_get_message_queue(PCB* target){
  return &(target->m_queue);
}

int32_t pcb_get_parent(PCB* target){
  return target->parent;
}

int32_t pcb_get_waiting_for(PCB* target){
  return target->waiting_for;
}

int32_t pcb_get_status(PCB* target){
  return target->status;
}

supervision_queue* pcb_get_supervisors(PCB* target){
  return &(target->supervisors);
}

supervision_queue* pcb_get_supervised(PCB* target){
  return &(target->supervised);
}
